package agents;

import game.constants.ReferenceAgent;
import game.constants.ReferenceObject;
import interfaces.impl.Agent;

import java.util.ArrayList;

import objects.WorldObject;
import universe.Universe;
import actions.ActionUniverseTransport;

public class AgentTransportPlayer extends Agent{
	

	@Override
	public void initializeActionList() {
		 
		
	}

	@Override
	public void initializeSpecialFeatures() {
		
		
	}

	@Override
	public void initializeName() {
		name= "Agent Transport Player";
		
	}

	@Override
	public void initializeId() {
		this.id=ReferenceAgent.AGENT_TRANSPORT_PLAYER;
		
	}

	@Override
	public void updateChild(WorldObject object, Universe universe, double time) {
		
		double x1= object.getPosition().getX();
		double x2= object.getImageObject().getPosition().getX()+object.getImageObject().getImageToShow().getWidth();
		double y1= object.getPosition().getY();
		double y2= object.getImageObject().getPosition().getY()+object.getImageObject().getImageToShow().getHeight();

	/*	System.out.println("x1 "+x1);
		System.out.println("x2 "+x2);
		System.out.println("y1 "+y1);
		System.out.println("y2 "+y2);
		System.out.println("width: "+object.getImageObject().getImageToShow().getWidth());
		System.out.println("height: "+object.getImageObject().getImageToShow().getHeight());
		*/
		
		ArrayList<WorldObject> list = universe.getObjects(x1, y1, x2, y2,ReferenceObject.OBJECT_REFERENCE_PLAYER);
		
		
		if(list.isEmpty()){
			return;
		}
		
		for(WorldObject obj : list){
			
				System.out.println("ENCONTRE UN PALAYER A TRANSPORTAR "+list.size());
				ActionUniverseTransport actionUniverseTransport = new ActionUniverseTransport();
				actionUniverseTransport.setSource(object);
				actionUniverseTransport.setTarget(obj);
				actionUniverseTransport.setUniverseIdToTransport(2);
				universe.setAction(actionUniverseTransport);
			
		}
		
	}
	
	

}
